<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>-用户欢迎</title>

    <link rel="shortcut icon" href="favicon.ico">
    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">

    <style type="text/css">
        .left {
            float: left;
        }

        .right {
            float: right;
        }
    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>咨询记录</h5>


                </div>
                <div class="ibox-content">

                    <table class="footable table table-stripped toggle-arrow-tiny" data-page-size="8">
                        <thead>
                        <tr>

                            <th data-toggle="true">问题详情</th>
                            <th>科室</th>
                            <!--<th>提交时间</th>-->
                            <th data-hide="all">问题详情</th>

                            <th data-hide="all">医师</th>
                            <th data-hide="all">回答</th>
                            <th>状态</th>
                        </tr>
                        </thead>
                        <tbody id="tbody">
                        <tr>
                            <td>脑瓜子疼</td>
                            <td>儿科</td>
                            <td>脑瓜子疼</td>
                            <td>李时珍</td>
                            <td><span class="pie">建议砍头</span></td>

                            <!--<td>2015.09.10</td>-->
                            <td><a href="#"><i class="fa fa-check text-navy"></i> 已回答</a></td>
                        </tr>

                        </tbody>
                        <tfoot>
                        <tr>
                            <td colspan="5">
                                <ul class="pagination pull-right"></ul>
                            </td>
                        </tr>
                        </tfoot>
                    </table>

                </div>
            </div>
        </div>
    </div>

</div>

</body>
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>
<script src="js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="js/plugins/layer/layer.min.js"></script>
<script src="js/plugins/footable/footable.all.min.js"></script>

<!-- 自定义js -->
<script>

    var list = null;
    $(document).ready(function() {
        getOldQuestion();
        $('.footable').footable();
        $('.footable2').footable();

    });

    function getOldQuestion() {
        $.ajax({
            async: false,
            type: "post",
            url: "/getOldQuestion",
            contentType: 'application/json',
            dataType: "text",
            success: function (data) {
                var result = JSON.parse(data);
                console.log(result);
                if (result.SUCCESS) {
                    list = result.RESULT;
                    console.log(list);
                    makeList(list)
                } else {
                    console.log(result.RESULT);
                }
            },
            error: function (data) {
                alert("请求失败");
            }
        });

    }

    /**
     * {"MESSAGE":"成功","SUCCESS":true,"VALIDATE":true,"RESULT":[{"answer":"你才是","docName":"丁医生","doctor":1001,"id":1000,"question":"你是傻逼吗？","room":"耳鼻喉科","status":"0","user":111,"userName":"ding"},
     * {"doctor":0,"id":1001,"question":"dafddafdsasf","room":"儿科","status":"0","user":111,"userName":"ding"}]}
     */

    function makeList(list) {
        /**
         * <th data-toggle="true">问题详情</th>
         <th>科室</th>
         <!--<th>提交时间</th>-->
         <th data-hide="all">问题详情</th>

         <th data-hide="all">医师</th>
         <th data-hide="all">回答</th>
         <th>状态</th>
         * @type {string}
         */

        var html = "";
        for (var i = 0; i < list.length; i++) {
            html += " <tr><td>" + list[i].message + "</td>    ";
            html += " <td>" + list[i].room + "</td>";
            html += " <td>" + list[i].message + "</td>";
            if(typeof( list[i].docName) == "undefined"){
                html += " <td>" + "无" + "</td>";
            }else{
                html += " <td>" + list[i].docName + "</td>";
            }
            if(typeof( list[i].answer) == "undefined"){
                html += " <td>" + "无" + "</td>";
            }else{
                html += " <td>" + list[i].answer + "</td>";
            }
            if(list[i].status == 0){
                html += " <td>" + "未处理" + "</td> </tr>";
            }else{
                html += " <td>" + "已处理" + "</td> </tr>";
            }
        }
        $('#tbody').html(html);
        console.log(html);
    }














</script>


<!--<script src="js/user.js"></script>-->
</html>
